﻿using System.Data;

namespace BLL
{
    /// <summary>
    /// 科目名称方法
    /// </summary>
    public class Yx_KeMuNameBLL : BaseBLL
    {
        /// <summary>
        /// 查询上级
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public string selectVid(string Vid)
        {
            string dd = "";
            string sql = @"select bb|| '--' ||aa dd,id idd from (
 select ke.kmnum || '_' || ke.kmname bb,c.aa,c.id from  yx_kemuname ke,
(select k.kmnum || '_' || k.kmname aa,k.fatherid,k.id
	from  yx_kemuname k
 where k.id=" + Vid + @") c  where
	  c.fatherid=ke.id)";

            DataTable dt = Query(sql);
            if (dt != null || dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    dd = item[0].ToString();
                }
            }

            sql = @"select ke.kmnum || '_' || ke.kmname|| '--' ||d.dd, d.idd
	from (select bb || '--' || aa dd, id idd, fatherid
					from (select ke.kmnum || '_' || ke.kmname bb,
											 c.aa,
											 c.id,
											 ke.fatherid fatherid
									from yx_kemuname ke,
											 (select k.kmnum || '_' || k.kmname aa, k.fatherid, k.id
													from yx_kemuname k
												 where k.id = " + Vid + @") c
								 where c.fatherid = ke.id)) d,
			 yx_kemuname ke
 where d.fatherid = ke.id	";

            dt = Query(sql);
            if (dt != null || dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    dd = item[0].ToString();
                }
            }
            return dd;
        }
    }
}